package flc.ast;

import android.view.View;

import androidx.annotation.NonNull;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import flc.ast.databinding.ActivityHomeBinding;
import flc.ast.fragment.AlbumFragment;
import flc.ast.fragment.AudioEditFragment;
import flc.ast.fragment.HomeFragment;
import flc.ast.fragment.MyFragment;
import flc.ast.fragment.TransferFragment;
import stark.common.basic.base.BaseNoModelActivity;
import stark.common.basic.base.BaseTabFragmentHomeActivity;
import stark.common.basic.base.DefExitAppDialog;
import stark.common.basic.event.EventStatConstant;
import stark.common.basic.event.EventStatProxy;
import stark.common.basic.utils.StatusBarUtils;

public class HomeActivity extends BaseTabFragmentHomeActivity<ActivityHomeBinding> implements View.OnClickListener {

    @Override
    protected int getPageType() {
        return EventStatConstant.PAGE_TAB_HOME;
    }

    @Override
    protected void onHandleStatusBar() {
        super.onHandleStatusBar();
        //设置状态栏字体颜色
        StatusBarUtils.setSystemStatusTextColor(false, this);
    }

    @Override
    protected void initView() {
        super.initView();
        EventStatProxy.getInstance().statLaunch(this);
        mDataBinding.llHomeBottom.setOnClickListener(null);
    }

    @NonNull
    @Override
    protected List<BaseTabFragmentHomeActivity<ActivityHomeBinding>.FragmentViewBinder> getFragmentViewBinders() {
        List<FragmentViewBinder> listFragment = new ArrayList<>();
        listFragment.add(new FragmentViewBinder(HomeFragment.class, R.id.ivHome));
        listFragment.add(new FragmentViewBinder(TransferFragment.class, R.id.ivFileTransfer));
        listFragment.add(new FragmentViewBinder(AlbumFragment.class, R.id.ivPrivacyAlbum));
        listFragment.add(new FragmentViewBinder(AudioEditFragment.class, R.id.ivAudioEdit));
        listFragment.add(new FragmentViewBinder(MyFragment.class, R.id.ivMy));
        return listFragment;
    }

    @Override
    protected void onFragmentViewClick(View view) {
        clearSelection();
        int id = view.getId();
        if (id == R.id.ivHome) {
            mDataBinding.ivHome.setImageResource(R.drawable.aaxt);
        } else if (id == R.id.ivFileTransfer) {
            mDataBinding.ivFileTransfer.setImageResource(R.drawable.aawjcs);
        } else if (id == R.id.ivPrivacyAlbum) {
            mDataBinding.ivPrivacyAlbum.setImageResource(R.drawable.aasmxc);
        } else if (id == R.id.ivAudioEdit) {
            mDataBinding.ivAudioEdit.setImageResource(R.drawable.aaypbj);
        } else if (id == R.id.ivMy) {
            mDataBinding.ivMy.setImageResource(R.drawable.aagrzx);
        }
    }

    @Override
    protected int getFragmentContainerId() {
        return R.id.flHome;
    }

    @Override
    protected int onCreate() {
        return R.layout.activity_home;
    }

    private void clearSelection() {
        mDataBinding.ivHome.setImageResource(R.drawable.axt);
        mDataBinding.ivFileTransfer.setImageResource(R.drawable.awjcs);
        mDataBinding.ivPrivacyAlbum.setImageResource(R.drawable.asmxc);
        mDataBinding.ivAudioEdit.setImageResource(R.drawable.aypbj);
        mDataBinding.ivMy.setImageResource(R.drawable.agrzx);
    }

}